home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!austern
- From: brettb@acti-ct.com (Brett Bergquist)
- Newsgroups: comp.std.c++
- Subject: Is it legal to use 'this' in the initializer list of a constructor
- Date: 04 Apr 1996 10:15:41 PST
- Organization: PCNet -- Connecticut's Internet Service Provider.
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <3163b5ba.61651300@gateway>
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: Thu, 04 Apr 1996 11:48:43 GMT
- X-Newsreader: Forte Agent .99d/32.182
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMWQRzUy4NqrwXLNJAQGGhgH9GoLdc+G3dsy6+3mfyv0edabr39/K6IYr
- KfJ42xxgT6179LcnV8WJOOcGmZ2LWq+VwrJVLdG+VYdgm/mGGvmUYw==
- =C5au
- Originator: austern@isolde.mti.sgi.com
-
- consider the following classes:
-
- class bar;
- class foo
- {
- public:
- foo(bar* b) : m_b(b) {}
- private:
- bar* m_b;
- };
-
- class bar
- {
- public:
- bar() : m_f(this) {}
- // ^^^ is this legal
- private:
- const foo m_f;
- };
-
- Is the use of 'this' legal to initialize the constant foo member. If
- not, how does one get a pointer to object being constructed within
- the constructor initializer?
- ---
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-